﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;

public partial class admin_admins_create_account : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
    {
          string userid = Membership.GetUser(CreateUserWizard1.UserName).ProviderUserKey.ToString();
         DropDownList uni_id = (DropDownList)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("UniDropDownList");
         string comm = uni_id.SelectedItem.Text;

         
         MembershipUser User = Membership.GetUser(CreateUserWizard1.UserName);

        //try
         if (String.Compare(comm, "Global") == 0)
         {
             User.Comment = "Global Admin";
             Roles.AddUserToRole(User.UserName, "Role_Super_Admin");
         }
         else
         {             
             
             User.Comment = comm;
             Roles.AddUserToRole(User.UserName, "Role_Uni_Admin");
             ACSService.addUniAdmin(userid, int.Parse(uni_id.SelectedValue.ToString()));
         }

         Membership.UpdateUser(User);

        
        //Response.Redirect("success.aspx")
        //' Catch ex As Exception
        //'Membership.DeleteUser(CreateUserWizard1.UserName)
        //'Throw New Exception("Account not created")
        //' End Try
    }
    protected void CreateUserWizard1_SendingMail(object sender, MailMessageEventArgs e)
    {
        // Set MailMessage fields.
        e.Message.IsBodyHtml = true;
        // Replace placeholder text in message body with information 
        // provided by the user.
        //e.Message.Body = e.Message.Body.Replace("<%Password%>", "");
    }
}